#include <istream>
#include <cstdio>
using namespace std;
const int N=2e5+5;
int n;
int a[N],c[N];
long long ans;
void dfs(int pos,int colour,long long last){
    c[pos]=colour;
    for(int i=pos-1;i>=1;i--){
        if(c[i]==colour){
            last+= a[i]==a[pos]?a[i]:0;
            break;
        }
    }
    if(pos==n){
        ans=max(ans,last);
        return;
    }
    dfs(pos+1,0,last);
    dfs(pos+1,1,last);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        dfs(1,1,0);dfs(1,0,0);
        printf("%lld\n",ans);
    }
    return 0;
}
